<?php

class App {

  private static $_instances = array();
  public static $config = array();

//------------------------------------------------------------------------------
  public static function init( ) {
    if( empty( self::$config ) )
      self::$config = parse_ini_file('configs/config.ini', true);
  }

//------------------------------------------------------------------------------
  public static function get( $class, $params = null ) {
    if( !isset( self::$_instances[$class] ) ) { // create new instance
      try{
        if( $params )
          self::$_instances[$class] = new $class( $params );
        else
          self::$_instances[$class] = new $class( );
      }
      catch( Exception $e ) {
        die( 'Class "'.$class.'" cannot be created.' );
      }
    }
    return self::$_instances[$class];
  }
}

?>
